﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simulator
{
	public class BridgeTree
	{
		readonly Bridge _bridge;
		readonly uint _treeIndex;

		public BridgeTree (Bridge bridge, uint treeIndex)
		{
			_bridge = bridge;
			_treeIndex = treeIndex;
		}

		[TypeConverter (typeof (UInt16HexTypeConverter))]
		[DefaultValue ((object) (ushort) 0x8000)]
		[Description ("0–61440 in steps of 4096")]
		public ushort Priority
		{
			get { return _bridge.Wrapper.GetBridgePriority (TreeIndex); }
			set 
			{
				lock (_bridge.WrapperLock)
					_bridge.Wrapper.SetBridgePriority (TreeIndex, value, (uint) Environment.TickCount); 
			}
		}

		[Browsable (false)]
		public Bridge Bridge
		{
			get { return _bridge; }
		}

		public uint TreeIndex
		{
			get { return _treeIndex; }
		}
	}
}
